package com.jysz.certificate.persistence.model.system;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.jysz.webcore.ssh.entity.AbstractBaseEntity;


/**
 * 权限功能点
 * @author <a href="mailto:javaengine@outlook.com">Kaca Rich</a>
 *
 */
@Entity
@Table(name="sys_oper")
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
public class Oper extends AbstractBaseEntity<Long> implements IOper{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String code;
	
	private String name;
	
	private Menu parent;
	
	private List<RoleOperRef> RoleOperRefList = new ArrayList<RoleOperRef>();
	
	@Column(name="oper_code",columnDefinition="varchar(255)")
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	
	@Column(name="oper_name",columnDefinition="varchar(255)")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@SuppressWarnings("deprecation")
	@OneToMany(mappedBy="oper", fetch=FetchType.LAZY)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
		org.hibernate.annotations.CascadeType.DELETE,
        org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
	public List<RoleOperRef> getRoleOperRefList() {
		return RoleOperRefList;
	}
	public void setRoleOperRefList(List<RoleOperRef> roleOperRefList) {
		RoleOperRefList = roleOperRefList;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)  
	@JoinColumn(name = "_parent_id",columnDefinition="bigint(20)") 
	public Menu getParent() { 
		return parent;
	}
	public void setParent(Menu parent) {
		this.parent = parent;
	}
	
	@Override
	@Transient 
	public List<? extends IOper> getChilds() {
		return null;
	}
	
	
}
